package com.yeban.javase.day14.test2;

import java.io.*;
import java.util.LinkedHashMap;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/24
 *
 * 读取emp.txt文件，其信息为  张三#123 ，完成用户登录
 */
public class test2 {

    public static void main(String[] args) {
        File file = new File("src/com/yeban/javase/day14/test2/emp.txt");
        try(
                BufferedReader br = new BufferedReader(new FileReader(file));
                //PrintWriter pw = new PrintWriter(file);
        ) {
            String line = null;
            String user = "张三#123";
            boolean flag = false;
            while((line = br.readLine()) != null) {
                if(line.equals(user)) {
                    System.out.println("登录成功！");
                    flag = true;
                    break;
                }
            }
            if(!flag) {
                System.out.println("找不到此用户！");
            }


        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
